import Vue from 'vue'
import Vuex from 'vuex'
import createPersistedState from 'vuex-persistedstate'


Vue.use(Vuex)


const state = {
    currentSideNavIndex:0, //侧边当前路由索引路由
    sideTit:null,
    sideRouters:[],
    userName:"admin"
}
const mutations = {
    setCurrentSideNavIndex(state,payload){
        state.currentSideNavIndex = payload
    },
    setSideRouters(state,payload){
        state.sideRouters = payload
    },
    setSideTit(state,payload){
        state.sideTit = payload
    }
}

export default new Vuex.Store({
    state,
    mutations,
    plugins: [createPersistedState()]//会自动保存创建的状态。刷新还在
});